# 13. Robot Network Configuration
## 13.1 Network Configuration Overview
The robot's network can be configured in two modes:
(1) AP Mode: The controller creates a hotspot that can be connected to by a smartphone. (Note: This mode does not connect to the external internet.)
(2) STA mode: The controller connects directly to a specified hotspot/Wi-Fi network. (This mode allows access to the external internet.)
By default, the robot operates in AP (direct connection) mode. The features and functions of the robot remain the same whether in AP mode or STA (local area network) mode.
## 13.2 AP Direct Connection Mode
### 13.2.1 Mode Switching through Phone
**Using the Android system as an example, these instructions also apply to iOS.**
(1) Open the **"WonderPi"** app on your phone. Then, go to **"Advanced"** and select **"MentorPi"**.
(2) Tap the **"+"** button in the bottom right corner of the screen, and choose **"Direct Connection Mode"**.
:::{Note}
If you prefer to connect in LAN mode, refer to [13.3 Connecting in LAN Mode (optional)](#anchor_13_3).
:::
(3) Tap **"Go to Connect Device Hotspot"**. This will take you to your phone's settings to connect to the hotspot created by the robot.
(4) Look for a hotspot name starting with **"HW"**. The password is **"hiwonder"**.
:::{Note}
For iOS: Wait until the Wi-Fi icon
appears in your phone's status bar before returning to the app. If you don't see the device listed, you can refresh by tapping the refresh icon
in the upper-right corner of the app.
:::
(5) Return to the app, and tap the robot icon to enter the mode selection screen.
:::{Note}
If a pop-up message appears saying **"Network Unavailable, Continue Connection?"**, simply tap **"Keep Connection"**.
:::
(6) If you see a prompt asking **"Whether to switch to and enter the searched interface?"**, it indicates that an incorrect product version was selected in Step 1. Tap **"CONFIRM"** to switch directly to the correct version's mode selection screen.
(7) The mode selection screen appears as shown below:
For details on each mode, refer to the documentation provided earlier.
### 13.2.2 Switching via Network Configuration File
(1) Power on the robot and connect it to the remote control software, VNC.
(2) Double-click the terminal icon
on the desktop to open the command line terminal.
(3) Enter the command and press Enter to navigate to the configuration file directory.
```
cd hiwonder-toolbox/
```
(4) Enter the command and press Enter to open the configuration file.
```
vim wifi_conf.py
```
:::{Note}
The configuration file defaults to AP Direct Connection Mode. If all code lines are commented out, it will be set to AP Direct Connection Mode.
:::
(5) If there are multiple devices nearby, you can modify `HW_WIFI_AP_SSID` and `HW_WIFI_AP_PASSWORD` to set a unique name and password for each device. For example, use **"HW-Robot"** as the name and **"hiwonder"** as the password, as shown below.
(6) After verifying the entries, press the **ESC** key, then type ``:wq`` to save and exit the file.
(7) Enter the command to restart the robot's Wi-Fi service.
```
sudo systemctl restart wifi.service
```
(8) Wait for the service to restart. You should see that the hotspot has been successfully updated.
(9) To connect using VNC, enter the new IP address in the search bar, and click on the connection icon that appears. Log in with the username **"pi"** and password **"raspberrypi"**, then click **"OK"** to access the system desktop.
(2) Open the **"WonderPi"** app on your phone, then select **"Advanced"** and **"MentorPi"**.
(3) Tap the **"+"** button in the bottom right corner, and choose **"LAN Mode"**.
(4) The app will prompt you to enter the password for the connected Wi-Fi network. (Please ensure the password is correct, as an incorrect password will result in connection failure.) After entering the password, tap **"OK"**.
(5) Tap **"Go to connect device hotspot"**.
(6) Your phone will automatically navigate to the Wi-Fi settings page. Find the hotspot starting with **"HW"** and enter the password **"hiwonder"**. Once connected, tap the **"Return"** button.
(7) The app will now begin the connection process.
(8) After a short wait, the robot's icon will appear on the main screen, and the LED on the expansion board will remain steadily lit.
(9) Press and hold the robot icon in the app to view the robot's assigned IP address and device ID.
(10) Use a remote desktop tool to search for the robot's IP address and connect to the remote desktop.
(11) To switch back to direct connection mode from LAN mode, press and hold the `KEY1` button on the expansion board until the blue LED flashes, indicating that the switch is complete.
### 13.3.2 Switching via Network Configuration File
(1) Power on the robot and connect it to the remote control software, NoMachine.
(2) Click the terminal icon
at the top of the system screen to open the command line terminal.
(3) Enter the command and press Enter to access the configuration file directory.
```
cd hiwonder-toolbox
```
(4) Enter the command and press Enter to open the configuration file.
```
vim wifi_conf.py
```
(5) First, change the value of `HW_WIFI_MODE` to 2:
① 1 represents Direct Connection Mode
② 2 represents LAN Mode
③ 3 represents Direct Sharing Mode
(6) Next, modify `HW_WIFI_STA_SSID` and `HW_WIFI_STA_PASSWORD` to match your router's Wi-Fi name and password.
:::{Note}
Selecting a 5G Wi-Fi signal will provide higher transfer speeds. If there is lag on standard Wi-Fi, consider switching to a 5G signal.
:::
(7) After confirming the entries are correct, press the **ESC** key, then type **:wq** to save and exit the file.
(8) Enter the following command to restart the robot's Wi-Fi service.
```
sudo systemctl restart wifi.service
```
(9) To switch back to Direct Connection Mode, edit the configuration file again, comment out all lines, save, and restart.